package com.ruoyi.web.controller.yf;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yf.domain.YfNotice;
import com.ruoyi.yf.service.IYfNoticeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 条形码 通知记录Controller
 * 
 * @author XiaoYi...
 * @date 2020-03-17
 * 36de1249-b306-4ae4-821c-dfcf1bebd0e8
 */
@Controller
@RequestMapping("/yf/notice")
public class YfNoticeController extends BaseController
{
    private String prefix = "yf/notice";

    @Autowired
    private IYfNoticeService yfNoticeService;

    @RequiresPermissions("yf:notice:view")
    @GetMapping()
    public String notice()
    {
        return prefix + "/notice";
    }

    /**
     * 查询条形码 通知记录列表
     * 2f3f88f3-9566-4ed6-9162-e592782ecbde
     */
    @RequiresPermissions("yf:notice:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfNotice yfNotice)
    {
        startPage();
        List<YfNotice> list = yfNoticeService.selectYfNoticeList(yfNotice);
        return getDataTable(list);
    }

    /**
     * 导出条形码 通知记录列表
     * ab5e66b4-0edf-46f2-9487-da5476f7b23d
     */
    @RequiresPermissions("yf:notice:export")
    @Log(title = "条形码 通知记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YfNotice yfNotice)
    {
        List<YfNotice> list = yfNoticeService.selectYfNoticeList(yfNotice);
        ExcelUtil<YfNotice> util = new ExcelUtil<YfNotice>(YfNotice.class);
        return util.exportExcel(list, "notice");
    }

    /**
     * 新增条形码 通知记录
     * 399230e0-f308-46e1-b049-488ad3f52a09
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存条形码 通知记录
     * a18ac3fd-e8f3-4b32-af67-b35d00b28265
     */
    @RequiresPermissions("yf:notice:add")
    @Log(title = "条形码 通知记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YfNotice yfNotice)
    {
        return toAjax(yfNoticeService.insertYfNotice(yfNotice));
    }

    /**
     * 修改条形码 通知记录
     * 22437202-48c2-4022-b3e8-4aa6e325010a
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YfNotice yfNotice = yfNoticeService.selectYfNoticeById(id);
        mmap.put("yfNotice", yfNotice);
        return prefix + "/edit";
    }

    /**
     * 修改保存条形码 通知记录
     * 637f531c-c1e6-4b88-863a-13942f2ec407
     */
    @RequiresPermissions("yf:notice:edit")
    @Log(title = "条形码 通知记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YfNotice yfNotice)
    {
        return toAjax(yfNoticeService.updateYfNotice(yfNotice));
    }

    /**
     * 删除条形码 通知记录
     * e933f7dd-56d0-492e-8735-2bc9cda3bf1e
     */
    @RequiresPermissions("yf:notice:remove")
    @Log(title = "条形码 通知记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yfNoticeService.deleteYfNoticeByIds(ids));
    }
}
